set more off

use "gss", clear

replace relig = 3 if relig >= 3 & !mi(relig) & relig!= 4

label define religl 1 "Protestant" 2 "Catholic" 3 "Other" 4 "None", replace
label values relig religl

**EVANGELICAL PROTESTANT**
g evan = 1 if denom == 10 | denom == 18 | denom == 32 | denom == 15 | denom == 34 | ///
denom == 23 | denom == 42 | denom == 14 | denom == 33 | other == 10 | other == 111 ///
| other == 107 | other == 138 | other == 12 | other == 109 | other == 20 | other == 22 ///
| other == 132 | other == 110 | other == 122 | other == 102 | other == 135 | other == 108 ///
| other == 29 | other == 9 | other == 125 | other == 28 | other == 31 | other == 32 ///
| other == 26 | other == 101 | other == 36 | other == 35 | other == 34 | other == 127 ///
| other == 121 | other == 5 | other == 116 | other == 39 | other == 41 | other == 42 ///
| other == 43 | other == 2 | other == 91 | other == 45 | other == 47 | other == 112 ///
| other == 120 | other == 139 | other == 124 | other == 51 | other ==53 | other == 13 ///
| other == 16 | other == 52 | other == 100 | other == 90 | other == 18 | other == 55 ///
| other == 24 | other == 3 | other == 134 | other == 146 | other == 129 | other == 131 ///
| other == 63 | other == 115 | other == 93 | other == 117 | other == 92 | other == 65 ///
| other == 6 | other == 27 | other == 97 | other == 68 | other == 66 | other == 67 ///
| other == 69 | other == 140 | other == 57 | other == 133 | other == 76 | other == 77 ///
| other == 94 | other == 106 | other == 118 | other == 83 | other == 84
replace evan = 1 if denom == 70 & attend > 3
replace evan = 0 if evan != 1

**MAINLINE PROTESTANT**
g main = 1 if denom == 11 | denom == 30 | denom == 50 | denom == 35 | denom == 31 ///
| denom == 38 | denom == 28 | denom == 40 | denom == 48 | denom == 43 | denom == 22 ///
| denom == 41 | other == 99 | other == 19 | other == 25 | other == 40 | other ==  44 ///
| other == 46 | other ==  49 | other ==  48 | other ==  50 | other ==  54 | other ==  89 ///
| other == 1 | other ==  105 | other ==  8 | other == 70 | other == 71 | other == 73 ///
| other == 72 | other == 148 | other == 23 | other == 119 | other == 81 | other == 96
replace main = 0 if main != 1

**CATHOLIC**
g cath=relig==3

**INTERACTIONS**
g attendXmain = attend*main
g attendXcath = attend*cath

local control income male married family_size age hs coll grad white black i.region

local j = 1
foreach y in ln_totgiv ln_givcong ln_givoth ln_givsec{
local mytitle: var label `y'	
	eststo: xi: reg `y' attend main cath attendXmain attendXcath `control' if (cath==1 | evan==1 | main==1)
	eststo: xi: reg `y' republican independent attend main cath attendXmain attendXcath `control' if (cath==1 | evan==1 | main==1)
local j = `j' + 1
}

label variable main "Mainline Protestant"
label variable cath "Catholic"
label variable attendXmain "Mainline X attend"
label variable attendXcath "Catholic X attend"

#delimit; 

esttab
	using "tableA2.tex", 
	replace
	compress
	stats(N r2, fmt(%20.00fc %20.02fc) label("Sample size" "R-squared"))
	booktabs
	cells(b(fmt(2) star) se(par))
	label
 	drop(*region*) 
 	width(\textwidth)
	mgroups(
	"Total" "Congregation" "Other Religious" "Secular"
			,
				pattern(1 0 1 0 1 0 1 0)
					prefix(\multicolumn{@span}{c}{) suffix(})
				span erepeat(\cmidrule(lr){@span})
		)	
		nomtitles
	;

#delimit cr

